package es.uji.viselab.world;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import javax.swing.JPanel;

import es.uji.viselab.ViSeLabComponent;
import es.uji.viselab.math.Matrix4;

public abstract class World implements ViSeLabComponent {

	Matrix4 targetPose;

	protected Set<WorldListener> notifiers = new HashSet<WorldListener>();

	protected void notifyWorldChanged(World world) {
		Iterator<WorldListener> itr = notifiers.iterator();
		while (itr.hasNext()) {
			WorldListener wl = itr.next();
			wl.worldChanged(world);
		}
	}

	public void addListener(WorldListener wl) {
		notifiers.add(wl);
	}

	public void removeListener(WorldListener wl) {
		notifiers.remove(wl);
	}

	public Matrix4 getTargetPose() {
		return targetPose;
	}

	public void setTargetPose(Matrix4 targetPose) {
		this.targetPose = targetPose;
	}

	public abstract JPanel getPanel();

}
